﻿using M_Purchase.Api.Appliction.Command.PurchCommand;
using M_Purchase.Repository.PurchaseInterface;
using MediatR;

namespace M_Purchase.Api.Appliction.CommandHandlers.PurchCommandHandler
{
    /// <summary>
    /// 新增采购信息
    /// </summary>
    public class PurchCreateCommandHandler : IRequestHandler<PurchCreateCommand, int>
    {
        private readonly IPurchRepository _purchRepository;
        public PurchCreateCommandHandler(IPurchRepository purchRepository)
        {
            _purchRepository = purchRepository;
        }
        public async Task<int> Handle(PurchCreateCommand request, CancellationToken cancellationToken)
        {
            return await _purchRepository.AddAsync(request);
        }
    }
}
